<template>
  <div :class="{'showNav':showNav,'bar' : true}" @mouseover="handleMouseOver" @mouseleave="handleMouseLeave">
    <div :class="{'showNavBar':showNav,'navBar':true}"
          v-for="item in navInformation"
    >
      <navSelect :navTitle="item.navTitle"
                 :routerTo="item.routerTo"
                 :isShow="showNav"
      >
        <template #iconSelect>
          <el-icon :size="20">
            <component :is="item.icon"></component>
          </el-icon>
        </template>
      </navSelect>
    </div>
  </div>
  <whiteCurtain v-if="showNav" :Configure="whiteCurtainConfigure"></whiteCurtain>
</template>

<script setup>
import {HomeFilled, Avatar, Comment, Grid, BellFilled} from '@element-plus/icons-vue'
import navSelect from './navSelect.vue'
import whiteCurtain from '../whiteCurtain.vue'
import { ref } from 'vue'
import { showNavState } from '@/stores/showNavState.js'
const NavStore = showNavState()

const navInformation = ref([
  // {
  //   navTitle: '导航',
  //   routerTo: 'navigation',
  //   icon: Promotion
  // },
  {
    navTitle: '首页',
    routerTo: 'home',
    icon: HomeFilled
  },
  {
    navTitle: '分类',
    routerTo: 'chat',
    icon: Grid
  },
  {
    navTitle: '消息',
    routerTo: 'message',
    icon: Comment
  },
  {
    navTitle: '订单中心',
    routerTo: 'order',
    icon: BellFilled
  },
  {
    navTitle: '个人中心',
    routerTo: 'personal',
    icon: Avatar
  }

])
const showNav = ref(false)
const whiteCurtainConfigure = ref({
  width: '97.5%',
  height: '92vh',
  top:'8vh',
  left:'2.5%',
})

function handleMouseOver() {
  showNav.value = true
  NavStore.turnNavStateToTrue()
}

function handleMouseLeave() {
  showNav.value = false
  NavStore.turnNavStateToFalse()
}

</script>

<style scoped>
.bar{
  border-bottom-left-radius: 4px;
  border-bottom-right-radius: 4px;
  height: 100%;
  width: 2.5%;
  /* background-color: #a0cfff; */
  background-color: #ffffff;
  border-right: 1px solid #79bbff;
  display: flex;
  align-items: center;
  flex-direction: column;
  transition: all 0.4s ease-in-out;
  position: fixed;
  top: 8vh;
  z-index: 1000;
}
.showNav{
  width: 10%;
}
.navBar{
  height: 5%;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.4s ease-in-out;
}
.showNavBar{
  height: 8%;
}
</style>
